package cn.hust.springboot.service.impl;

import cn.hust.springboot.bean.PositionExample;
import cn.hust.springboot.bean.Salary;
import cn.hust.springboot.bean.SalaryExample;
import cn.hust.springboot.mapper.SalaryMapper;
import cn.hust.springboot.service.ISalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SalaryServiceImpl implements ISalaryService {
    @Autowired
    private SalaryMapper salaryMapper;

    @Override
    public Salary getSalaryById(Integer id) {
        return salaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Salary> getAllSalarys() {
        SalaryExample example = new SalaryExample();
        SalaryExample.Criteria criteria = example.createCriteria();
        criteria.getAllCriteria();
        return this.salaryMapper.selectByExample(example);
    }

    @Override
    public int deleteSalaryById(Integer id) {
        return salaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int addSalary(Salary salary) {
        return salaryMapper.insert(salary);
    }

    @Override
    public int updateSalary(Salary salary) {
        return salaryMapper.updateByPrimaryKey(salary);
    }
}
